package com.yidu.manage.service.system;

import com.yidu.common.utils.StringUtils;
import com.yidu.manage.domain.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("ss")
public class PermissionService
{
    @Autowired
    private CurrentUser currentUser;

    /**
     * 验证用户是否具备某权限
     *
     * @param permission 权限字符串
     * @return 用户是否具备某权限
     */
    public boolean hasPermit(String permission)
    {
//        SELECT m.* FROM t_sys_user u
//        LEFT JOIN t_sys_user_role ur on u.id=ur.user_id
//        LEFT JOIN t_sys_role_menu rm on rm.role_id = ur.role_id
//        LEFT JOIN t_sys_menu m on ur.role_id = m.id
//        WHERE u.id=1 and m.perms='system:user:list' LIMIT 1
        LoginUser user = CurrentUser.getCurrentUser();
        if (StringUtils.isEmpty(permission))
        {
            return true;
        }
        return true;
        // return user.getPermissions().contains(permission);
    }
}
